import axios from 'axios';

export async function Resultlist() {
  return axios.get('http://localhost:8080/Result/list')
    .then(response => response.data);
}

export async function ResultDownload(record) {
  return axios({
    method:"post",
    responseType: 'blob',
    url:"http://localhost:8080/Result/download",
    data: record
  }).then(function (res){
    if (!res.data) {
      return
    }
    let url = window.URL.createObjectURL(new Blob([res.data]))
    let link = document.createElement('a')
    link.style.display = 'none'
    link.href = url
    link.setAttribute('download', record.name)
    document.body.appendChild(link)
    link.click()
    // 释放URL对象所占资源
    window.URL.revokeObjectURL(url)
    // 用完即删
    document.body.removeChild(link)
  })
}

export async function ResultData(record) {
  return axios({
    method:"post",
    url:"http://localhost:8080/Result/resultlist",
    data: record
  })
}

export async function resultDelete(record) {
  return axios({
    method:"delete",
    url:"http://localhost:8080/Result/delete",
    data: record
  })
}
